package Overlapping;


import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.util.regex.Pattern;

public class UMisc {

	private static final CharsetEncoder ASCII_ENCODER = Charset.forName(
			"US-ASCII").newEncoder(); // or "ISO-8859-1" for ISO Latin 1

	private static final Pattern DIGIT_PATTERN = Pattern.compile("[\\d]+");
	private static final Pattern NUMBER_PATTERN = Pattern
			.compile("[\\+\\-]?[\\d]+(\\.[\\d]+)?");

	public static boolean isAscii(String v) {
		return ASCII_ENCODER.canEncode(v);
	}

	public static boolean isDigit(String v) {
		return DIGIT_PATTERN.matcher(v).matches();
	}

	public static boolean isNumber(String v) {
		return NUMBER_PATTERN.matcher(v).matches();
	}

}
